﻿using DevExpress.Utils.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace OneSys.Misc
{
    /// <summary>
    /// Interaction logic for SNWindow.xaml
    /// </summary>
    public partial class SNWindow : Window
    {
        FrmSN snWindow = null;
        private bool is_regist_clicked = false;
        public SNWindow()
        {
            InitializeComponent();
            this.Owner = Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive);
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            snWindow = new FrmSN();
            this.Title = snWindow.Text;
            this.Height = snWindow.Height;
            this.Width = snWindow.Width;
        }


        private void Grid_Loaded(object sender, RoutedEventArgs e)
        {
            var host = new System.Windows.Forms.Integration.WindowsFormsHost();

            // Create the MaskedTextBox control.

            snWindow.TopLevel = false;
            snWindow.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            // Assign the MaskedTextBox control as the host control's child.
            host.Child = snWindow;
            // Add the interop host control to the Grid
            // control's collection of child controls.
            this.frameSN.Children.Add(host);

            snWindow.btnRegist.Click += (o, args) =>
            {

                if (is_regist_clicked)
                {
                    this.DialogResult = true;
                    this.Close();
                }
                is_regist_clicked = false;

            };

            snWindow.Closed += (o, args) =>
            {
                is_regist_clicked = true;
       
            };
        }


}
}
